#include "mainwindow.h"
#include "customtreeview.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{

    //menu
    QMenu *fileMenu = new QMenu(tr("Operation"), this);
    renameAction = fileMenu->addAction(tr("Rename"));
    renameAction->setShortcut(Qt::Key_F2);
    connect(renameAction, SIGNAL(triggered()), this, SLOT(renameSelected()));
    copyAction = fileMenu->addAction(tr("Copy"));
    copyAction->setShortcut(Qt::Key_F5);
    connect(copyAction, SIGNAL(triggered()), this, SLOT(copySelected()));
    moveAction = fileMenu->addAction(tr("Move"));
    moveAction->setShortcut(Qt::Key_F6);
    connect(moveAction, SIGNAL(triggered()), this, SLOT(moveSelected()));
    deleteAction = fileMenu->addAction(tr("Del"));
    deleteAction->setShortcut(Qt::Key_Delete);
    connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteSelected()));
    menuBar()->addMenu(fileMenu);

    //left
    splitter = new QSplitter(this);
    viewLeft = new QCustomTreeView(this);
    viewRight = new QCustomTreeView(this);

    splitter->addWidget(viewLeft);
    splitter->addWidget(viewRight);

    setCentralWidget(splitter);

    statusBar();

    //set model
    model = new QFileSystemModel();
    model->setRootPath(QDir::rootPath());

    viewLeft->setModel(model);
    viewLeft->setRootIndex(model->index("C:/"));

    viewRight->setModel(model);
    viewRight->setRootIndex(model->index("D:/"));
}


MainWindow::~MainWindow()
{

}

void MainWindow::renameSelected()
{
    statusBar()->showMessage("rename");
}

void MainWindow::copySelected()
{
    statusBar()->showMessage("copy");
}

void MainWindow::moveSelected()
{
    statusBar()->showMessage("move");
}

void MainWindow::deleteSelected()
{
    statusBar()->showMessage("delete");
}
